//
//  JVButton.m
//  wtshoppingcite
//
//  Created by Baojia-LC on 14-10-18.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "JVButton.h"

@implementation JVButton

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    NSString *title = [self titleForState:UIControlStateNormal];
    CGSize titleSize = [title sizeWithFont:[UIFont systemFontOfSize:12.0f]];
    CGSize imageSize = [[self imageForState:UIControlStateNormal] size];
    
    CGFloat x = (contentRect.size.width - titleSize.width) / 2;
    CGFloat y = imageSize.height/2 + (contentRect.size.height - titleSize.height)/2 +5;
    
    return CGRectMake(x, y, contentRect.size.width, titleSize.height);
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    NSString *title = [self titleForState:UIControlStateNormal];
    CGSize titleSize = [title sizeWithFont:[UIFont systemFontOfSize:12.0f]];
    CGSize imageSize = [[self imageForState:UIControlStateNormal] size];
    
    CGFloat x = (contentRect.size.width - imageSize.height ) / 2;
    CGFloat y = 5;
    
    return CGRectMake(x, y, imageSize.width, imageSize.height);
}


@end
